import React, { Component } from 'react';
import moment from 'moment';
import { Consumer } from '../../base/context'

class MessageItem extends Component {
    render() {
        let { avatar, message, time } = this.props
        return (<Consumer>
            {obj => {
                return <div className='media'>
                    <div className="media-left">
                        <img src={avatar} alt='' />
                    </div>
                    <div className="media-body">
                        <h4 className="media-heading">{message}</h4>
                        <span>{moment(time).fromNow()}</span>
                        <hr />
                        <button className="btn btn-success" onClick={() => {obj.add()}}>点赞</button>
                    </div>
                </div>
            }}
        </Consumer>);
    }
}

export default MessageItem;